package org.programmers.anonymous.fightrobots.web.controller;

import org.programmers.anonymous.fightrobots.controller.IFightController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@Controller
@RequestMapping("/fight")
public class FightWebController implements BeanFactoryAware
{
	final Logger logger = LoggerFactory.getLogger(FightWebController.class);
	private IFightController fc = null;
		
	@RequestMapping(value="/", method = RequestMethod.GET)
	public String ListOfFight(ModelMap model)
	{
		/*
		Map<IURLId, IFight> theMap = fc.getHashFight();
		IRobot theRobotAc = new Robot();
		IRobot theRobotPs = new Robot();
		IFight theFight = new Fight();
		IURLId url = new URLId();
		
		theRobotAc.setName("Mazinger");
		theRobotPs.setName("Bender");
		
		theFight.setActiveRobot(theRobotAc);
		theFight.setPassiveRobot(theRobotPs);
		
		url.setRobotId("Bender");
		url.setURL("localhost:8080/fight-robots");
		
		theMap.put(url, theFight);
		*/
		model.addAttribute("hashFight", fc.getHashFight());
		//model.addAttribute("hashFight", theMap);
				
		return "listFight";
	}

	@Override
	public void setBeanFactory(BeanFactory context) throws BeansException
	{
		fc = (IFightController) context.getBean("fightControllerSingleton");
	}

}
